package com.mobilemoney.mm.adapter;

import android.app.Activity;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.mobilemoney.mm.MoreContentActivity;
import com.mobilemoney.mm.R;

public class MoreBaseAdapter extends BaseAdapter {

	private String[] moretitle = null;
	private LayoutInflater layoutInflater;
	
	Activity activity;

	public MoreBaseAdapter(Activity activity) {
		this.activity = activity;
		layoutInflater = LayoutInflater.from(activity.getApplicationContext());
		
		moretitle = activity.getResources().getStringArray(R.array.moretitle);
	}
	
	@Override
	public int getCount() {
		return moretitle.length;
	}

	@Override
	public Object getItem(int position) {
		return moretitle[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	class ViewHolder {
		TextView moretitle;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			convertView = layoutInflater.inflate(R.layout.viewpager3item, null);
			viewHolder = new ViewHolder();
			viewHolder.moretitle = (TextView) convertView.findViewById(R.id.moretitle);
			convertView.setTag(viewHolder);
		}else {
			viewHolder = (ViewHolder) convertView.getTag();
			
		}

		viewHolder.moretitle.setText(moretitle[position]);
		convertView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				System.out.println("item  click1!!!");
				
				Intent intent = new Intent();
				intent.setClass(activity, MoreContentActivity.class);
				activity.startActivity(intent);
			}

		});
		return convertView;
	}

}
